<?php
class Preferences {
    private $props = [];
    private static $instance;
    private function __construct()
    {
    }

    public function setProperty($key,$val)
    {
        $this->props[$key] = $val;
    }

    public function getProp($key)
    {
        return $this->props[$key];
    }

    public static function getInstance()
    {
        if(empty(self::$instance)) {
            self::$instance = new Preferences();
        }
        return self::$instance;
    }

    private function __clone()
    {
        // TODO: Implement __clone() method.
    }
}

$pref = Preferences::getInstance();
$pref->setProperty('name','xushihuan');
unset($pref);
$pref2 = Preferences::getInstance();
print $pref2->getProp('name');